﻿#include"contact.h"
//通讯录3.0版本，增加文件读取、存储数据


void Menu()
{
	printf("***************************\n");
	printf("**** 1.add    2.delete ****\n");
	printf("**** 3.search 4.modify ****\n");
	printf("**** 5.show   6.delall ****\n");
	printf("**** 7.sort   0.exit   ****\n");
	printf("***************************\n");
}


enum option
{
	EXIT,
	ADD,
	DELETE,
	SEARCH,
	MODIFY,
	SHOW,
	DELALL,
	SORT
};

int main()
{
	int input = 0;
	contact con;
	InitCon(&con);
	do
	{
		Menu();
		printf("请选择>\n");
		scanf("%d", &input);
		switch (input)
		{
		case EXIT:
			SaveContact(&con);
			DestroyData(&con);
			break;
		case ADD:
			AddData(&con);
			break;
		case DELETE:
			DeleteDate(&con);
			break;
		case SEARCH:
			SearchbyName(&con);
			break;
		case SHOW:
			ShowCon(&con);
			break;
		case MODIFY:
			ModifybyName(&con);
			break;
		case DELALL:
			DeleteALL(&con);
			break;
		case SORT:
			SortbyName(&con);
			break;
		default:
			printf("\n");
		}
	} while (input);

	return 0;
}